#include "stm32f10x.h"
#include "DHT11.h"
#include "OLED.h"


void TIME_init(void)
{
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);

	TIM_InternalClockConfig(TIM3);
	
	TIM_TimeBaseInitTypeDef TIM_TimeInitStruct;
	TIM_TimeInitStruct.TIM_ClockDivision=TIM_CKD_DIV1;
	TIM_TimeInitStruct.TIM_CounterMode=TIM_CounterMode_Up;
	TIM_TimeInitStruct.TIM_Period=10000-1;
	TIM_TimeInitStruct.TIM_Prescaler=3600-1;
	TIM_TimeInitStruct.TIM_RepetitionCounter=0;
	TIM_TimeBaseInit(TIM3, &TIM_TimeInitStruct);
	
	TIM_ClearFlag(TIM3, TIM_FLAG_Update);
	TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE);
	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	
	NVIC_InitTypeDef NVIC_InitStruct;
	NVIC_InitStruct.NVIC_IRQChannel=TIM3_IRQn;
	NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE;
	NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=2;
	NVIC_InitStruct.NVIC_IRQChannelSubPriority=2;
	NVIC_Init(&NVIC_InitStruct);
	
	TIM_Cmd(TIM3, ENABLE);
	
	
	
}
